<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Log_post_audit_m extends Base_model {
	public $primary_key = 'post_log_id';
	public $_table = 'log_post_audit';
	
	function post_change_status($post_id, $log_type = '', $old_status, $new_status)
	{
		if(!$post_id || $post_id <0 ) return FALSE;
		if(!$log_type || $log_type =='' ) return FALSE;
		if(!$old_status ) return FALSE;
		if(!$new_status ) return FALSE;
		$admin_id = $this->admin->id;
		$this->load->model('log_admin_activities_m');
		$title  = ($log_type =='down')?'Hạ tin':'Lên tin';
		$title = $title.' '.$post_id;
		$this->log_admin_activities_m->add($title,$old_status.','.$new_status,'success');
		return $this->insert(array(
			'post_id' =>$post_id,
			'admin_id' =>$admin_id,
			'log_type' =>$log_type,
			'log_time' => time(),
			'post_old_status' => $old_status,
			'post_new_status' => $new_status,
			));
	}
}
